export default {
	// 开启命名空间
	namespaced: true,
	state: {
		token: uni.getStorageSync("token") || "",
		userRegisted:JSON.parse(uni.getStorageSync("userRegisted") || "[]"),
		currentVaccine:{},
		userInfo: JSON.parse(uni.getStorageSync("userInfo") || "{}"),
	},
	mutations: {
		
		// 更新 token
		updateToken(state, payload) {
			state.token = payload;
			// 持久化存储到本地
			this.commit("m_user/saveTokenToStorage");
		},
		// 更新 疫苗
		updateVaccine(state, payload) {
			state.currentVaccine = payload;
			// 持久化存储到本地
			// this.commit("m_user/saveTokenToStorage");
		},
		// 持久化存储 token
		saveTokenToStorage(state) {
			// console.log(state.token); //@log
			uni.setStorageSync('token', state.token);
		},
		// 更新 UserRegisted
		updateUserRegisted(state, payload) {
			state.userRegisted = payload;
			// 持久化存储到本地
			this.commit("m_user/saveUserRegisted");
		},
		// 持久化存储 UserRegisted
		saveUserRegisted(state) {
			// console.log(state.token); //@log
			uni.setStorageSync('userRegisted', JSON.stringify(state.userRegisted));
		},
		// 更新用户的基本信息
		updateUserInfo(state, payload) {
			state.userInfo = payload;
			// 持久化存储到本地
			this.commit("m_user/saveUserInfoToStorage");
		},
		// 持久化存储用户信息
		saveUserInfoToStorage(state) {
			uni.setStorageSync('userInfo', JSON.stringify(state.userInfo));
		},
		

	},
	getters:{
		
	}

}
